package com.sky.his.api.schedule;

import com.sky.his.api.db.dao.OrderDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Component
@Slf4j
public class OrderSchedule {

    @Resource
    private OrderDao orderDao;

    @Scheduled(cron = "0 0 * * * ?")
    @Transactional
    public void closeUnPaymentOrder() {
        int rows = orderDao.closeOrder();
        if (rows > 0) {
            log.info("关闭了" + rows + "个未付款的订单");
        }
    }

}
